package cn.hanyx.consumer.service;

import cn.hanyx.consumer.bean.Depart;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * DepartServiceFallbackFactory
 *
 * @author hanyx
 * @date 2019/07/12
 */
@Component
public class DepartServiceFallbackFactory implements FallbackFactory<DepartService> {
    @Override
    public DepartService create(Throwable throwable) {
        return new DepartService() {

            @Override
            public boolean saveDepart(Depart depart) {
                System.out.println("执行saveDepart()的服务降级处理方法");
                return false;
            }

            @Override
            public boolean removeDepartById(Integer id) {
                System.out.println("执行 removeDepartById()的服务降级处理方法");
                return false;
            }

            @Override
            public boolean modifyDepart(Depart depart) {
                System.out.println("执行 modifyDepart()的服务降级处理方法");
                return false;
            }

            @Override
            public Depart getDepartById(Integer id) {
                System.out.println("执行 getDepartById()的服务降级处理方法");
                return new Depart();
            }

            @Override
            public List<Depart> listAllDeparts() {
                System.out.println("执行 listAllDeparts()的服务降级处理方法");
                return new ArrayList<>();
            }
        };
    }
}
